package com.xl.minyue.tc2.until;


import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class PIDate {
    private int year;
    private int month;
    private int day;
    private int hour;
    private int minutes;
    private int seconds;

    public int getYear() {
        return year;
    }
    public void setYear(int year) {
        this.year = year;
    }
    public int getMonth() {
        return month;
    }
    public void setMonth(int month) {
        this.month = month;
    }
    public int getDay() {
        return day;
    }
    public void setDay(int day) {
        this.day = day;
    }
    public int getHour() {
        return hour;
    }
    public void setHour(int hour) {
        this.hour = hour;
    }
    public int getMinutes() {
        return minutes;
    }
    public void setMinutes(int minutes) {
        this.minutes = minutes;
    }
    public int getSeconds() {
        return seconds;
    }
    public void setSeconds(int seconds) {
        this.seconds = seconds;
    }

    public static PIDate getPIDate(String time){
        Pattern p=Pattern.compile("(\\d{4})-(\\d{1,2})-(\\d{1,2}) (\\d{1,2}):(\\d{1,2}):(\\d{1,2})");
        Matcher m=p.matcher(time);
        PIDate date = new PIDate();
        if(m.find()){
            date.setYear(Integer.parseInt(m.group(1)));
            date.setMonth(Integer.parseInt(m.group(2)));
            date.setDay(Integer.parseInt(m.group(3)));
            date.setHour(Integer.parseInt(m.group(4)));
            date.setMinutes(Integer.parseInt(m.group(5)));
            date.setSeconds(Integer.parseInt(m.group(6)));
        }
        return date;

    }
}
